import {
  combineReducers,
  legacy_createStore,
  compose,
  applyMiddleware,
} from 'redux'
// reducer 导入准备的数据
import reducer1 from './Data/reducer'
import reducer2 from './Data1/reducer'
import reduxThunk from 'redux-thunk'

// 组个各个模块的 reducer
const reducers = combineReducers({
  reducer1,
  reducer2,
})

// 创建数据仓库，注册 reducer
// const store = legacy_createStore(
//   reducer,
//   window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__(),
// )

// 让 redux 调式工具兼容异步的处理
let composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
  ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({})
  : compose

// 把仓库数据，浏览器redux-dev-tools，还有reduxThunk插件关联在store中
const store = legacy_createStore(
  reducers,
  composeEnhancers(applyMiddleware(reduxThunk)),
)
// 导出
export default store
